package com.health.ts.controller.statistics;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.health.ts.constant.CustomPage;
import com.health.ts.constant.FrontPage;
import com.health.ts.constant.ApiResult;
import com.health.ts.controller.BaseController;
import com.health.ts.entity.statistics.VApplyCount;
import com.health.ts.entity.statistics.VApplyHospitalCost;
import com.health.ts.entity.statistics.VAssignCount;
import com.health.ts.entity.statistics.VConHospitalCost;
import com.health.ts.entity.statistics.VExpertCount;
import com.health.ts.entity.statistics.VHosConsulationCount;
import com.health.ts.entity.statistics.VHospitalApply;
import com.health.ts.entity.statistics.VQaafterCount;
import com.health.ts.entity.statistics.VQabeforeCount;
import com.health.ts.entity.statistics.VUserCost;
import com.health.ts.service.statistics.VApplyCountService;
import com.health.ts.service.statistics.VApplyHospitalCostService;
import com.health.ts.service.statistics.VAssignCountService;
import com.health.ts.service.statistics.VConHospitalCostService;
import com.health.ts.service.statistics.VExpertCountService;
import com.health.ts.service.statistics.VHosConsulationCountService;
import com.health.ts.service.statistics.VHospitalApplyService;
import com.health.ts.service.statistics.VQaafterCountService;
import com.health.ts.service.statistics.VQabeforeCountService;
import com.health.ts.service.statistics.VUserCostService;
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2017-07-05
 */
@RestController
@RequestMapping(value = "/api/applyCount",produces= BaseController.JSON_UTF8)
public class ApplyCountController extends BaseController{
	
	@Autowired
	VApplyCountService vapplyCountService;
	
	@Autowired
	VHospitalApplyService vhospitalApplyService;
	
	@Autowired
	VAssignCountService vassignCountService;
	
	@Autowired
	VHosConsulationCountService vhosConsulationCountService;
	
	@Autowired
	VQaafterCountService vqaafterCountService;
	
	@Autowired
	VQabeforeCountService vqabeforeCountService;
	
	@Autowired
	VExpertCountService vexpertCountService;
	
	@Autowired
	VApplyHospitalCostService vapplyHospitalCostService;
	
	@Autowired
	VConHospitalCostService vconHospitalCostService;
	
	@Autowired
	VUserCostService vuserCostService;
	
	@RequestMapping(value="/list", method=RequestMethod.POST)
	public ApiResult queryCount(@RequestBody FrontPage page) {
		QueryWrapper<VApplyCount> QueryWrapper = new QueryWrapper<VApplyCount>();
		String doc_name =getParam(page,"doc_name");
		if (StringUtils.isNotEmpty(doc_name)){
			QueryWrapper.like("doc_name", doc_name); 
		}
		Page<VApplyCount> pageList = vapplyCountService.page(page.getPagePlus(), QueryWrapper);
		CustomPage<VApplyCount> customPage = new CustomPage<VApplyCount>(pageList);
		return ApiResult.success(customPage);
	}
	
	/**
	 * @param page
	 * @return
	 */
	@RequestMapping(value="/listHospital", method=RequestMethod.POST)
	public ApiResult queryHospitalCount(@RequestBody FrontPage page) {
		QueryWrapper<VHospitalApply> QueryWrapper = new QueryWrapper<VHospitalApply>();
		String hospital_name =getParam(page,"hospital_name");
		if (StringUtils.isNotEmpty(hospital_name)){
			QueryWrapper.like("hospital_name", hospital_name); 
		}
		Page<VHospitalApply> pageList = vhospitalApplyService.page(page.getPagePlus(), QueryWrapper);
		CustomPage<VHospitalApply> customPage = new CustomPage<VHospitalApply>(pageList);
		return ApiResult.success(customPage);
	}
	
	/**
	 * 前质控工作量统计
	 * @param page
	 * @return
	 */
	@RequestMapping(value="/listQaBefore", method=RequestMethod.POST)
	public ApiResult listQaBeforeCount(@RequestBody FrontPage page) {
		QueryWrapper<VQabeforeCount> QueryWrapper = new QueryWrapper<VQabeforeCount>();
		String user_name =getParam(page,"user_name");
		if (StringUtils.isNotEmpty(user_name)){
			QueryWrapper.like("user_name", user_name); 
		}
		Page<VQabeforeCount> pageList = vqabeforeCountService.page(page.getPagePlus(), QueryWrapper);
		CustomPage<VQabeforeCount> customPage = new CustomPage<VQabeforeCount>(pageList);
		return ApiResult.success(customPage);
	}
	
	/**
	 * 后指控管理员工作量统计
	 * @param page
	 * @return
	 */
	@RequestMapping(value="/listAfter", method=RequestMethod.POST)
	public ApiResult listAfterCount(@RequestBody FrontPage page) {
		QueryWrapper<VQaafterCount> QueryWrapper = new QueryWrapper<VQaafterCount>();
		String user_name =getParam(page,"user_name");
		if (StringUtils.isNotEmpty(user_name)){
			QueryWrapper.like("user_name", user_name); 
		}
		Page<VQaafterCount> pageList = vqaafterCountService.page(page.getPagePlus(), QueryWrapper);
		CustomPage<VQaafterCount> customPage = new CustomPage<VQaafterCount>(pageList);
		return ApiResult.success(customPage);
	}
	
	/**
	 * 分诊工作量统计
	 * @param page
	 * @return
	 */
	@RequestMapping(value="/listAssign", method=RequestMethod.POST)
	public ApiResult listAssignCount(@RequestBody FrontPage page) {
		QueryWrapper<VAssignCount> QueryWrapper = new QueryWrapper<VAssignCount>();
		String user_name =getParam(page,"user_name");
		if (StringUtils.isNotEmpty(user_name)){
			QueryWrapper.like("user_name", user_name); 
		}
		Page<VAssignCount> pageList = vassignCountService.page(page.getPagePlus(), QueryWrapper);
		CustomPage<VAssignCount> customPage = new CustomPage<VAssignCount>(pageList);
		return ApiResult.success(customPage);
	}
	
	/**
	 * 医院会诊工作量
	 * @param page
	 * @return
	 */
	@RequestMapping(value="/listHosConsulation", method=RequestMethod.POST)
	public ApiResult listHosConsulationCount(@RequestBody FrontPage page) {
		QueryWrapper<VHosConsulationCount> QueryWrapper = new QueryWrapper<VHosConsulationCount>();
		String hospital_name =getParam(page,"hospital_name");
		if (StringUtils.isNotEmpty(hospital_name)){
			QueryWrapper.like("hospital_name", hospital_name); 
		}
		Page<VHosConsulationCount> pageList = vhosConsulationCountService.page(page.getPagePlus(), QueryWrapper);
		CustomPage<VHosConsulationCount> customPage = new CustomPage<VHosConsulationCount>(pageList);
		return ApiResult.success(customPage);
	}
	
	/**  
	* @Title: listExpertCountCount  
	* @Description: 专家会诊工作量 
	* @param @param page
	* @param @return    参数  
	* @return String    返回类型  
	* @throws  
	*/ 
	@RequestMapping(value="/listExpertCount", method=RequestMethod.POST)
	public ApiResult listExpertCountCount(@RequestBody FrontPage page) {
		QueryWrapper<VExpertCount> QueryWrapper = new QueryWrapper<VExpertCount>();
		String hospital_name =getParam(page,"hospital_name");
		if (StringUtils.isNotEmpty(hospital_name)){
			QueryWrapper.like("hospital_name", hospital_name); 
		}
		Page<VExpertCount> pageList = vexpertCountService.page(page.getPagePlus(), QueryWrapper);
		CustomPage<VExpertCount> customPage = new CustomPage<VExpertCount>(pageList);
		return ApiResult.success(customPage);
	}
	
	/**
	 * 医院申请费用
	 * @param page
	 * @return
	 */
	@RequestMapping(value="/listApplyHosCost", method=RequestMethod.POST)
	public ApiResult listApplyHosCost(@RequestBody FrontPage page) {
		QueryWrapper<VApplyHospitalCost> QueryWrapper = new QueryWrapper<VApplyHospitalCost>();
		String hospital_name =getParam(page,"hospital_name");
		if (StringUtils.isNotEmpty(hospital_name)){
			QueryWrapper.like("hospital_name", hospital_name); 
		}
		Page<VApplyHospitalCost> pageList = vapplyHospitalCostService.page(page.getPagePlus(), QueryWrapper);
		CustomPage<VApplyHospitalCost> customPage = new CustomPage<VApplyHospitalCost>(pageList);
		return ApiResult.success(customPage);
	}
	
	/**
	 * 医院会诊费用
	 * @param page
	 * @return
	 */
	@RequestMapping(value="/listConHosCost", method=RequestMethod.POST)
	public ApiResult listConHosCost(@RequestBody FrontPage page) {
		QueryWrapper<VConHospitalCost> QueryWrapper = new QueryWrapper<VConHospitalCost>();
		String hospital_name =getParam(page,"hospital_name");
		if (StringUtils.isNotEmpty(hospital_name)){
			QueryWrapper.like("hospital_name", hospital_name); 
		}
		Page<VConHospitalCost> pageList = vconHospitalCostService.page(page.getPagePlus(), QueryWrapper);
		CustomPage<VConHospitalCost> customPage = new CustomPage<VConHospitalCost>(pageList);
		return ApiResult.success(customPage);
	}
	/**
	 * 专家会诊费用
	 * @param page
	 * @return
	 */
	@RequestMapping(value="/listConUserCost", method=RequestMethod.POST)
	public ApiResult listConUserCost(@RequestBody FrontPage page) {
		QueryWrapper<VUserCost> QueryWrapper = new QueryWrapper<VUserCost>();
		String hospital_name =getParam(page,"hospital_name");
		if (StringUtils.isNotEmpty(hospital_name)){
			QueryWrapper.like("hospital_name", hospital_name); 
		}
		Page<VUserCost> pageList = vuserCostService.page(page.getPagePlus(), QueryWrapper);
		CustomPage<VUserCost> customPage = new CustomPage<VUserCost>(pageList);
		return ApiResult.success(customPage);
	}
}
